/*MyPhotoIndex Free Photo Organizer <www.myphotoindex.com>
  Copyright (C) <2006-2008>  <Asaf Yarkoni asaf@myphotoindex.com>

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.*/

#pragma once

using namespace MyPhotoIndex::Interfaces::ImageFormatProviders;
using namespace MyPhotoIndex::Interfaces::Imaging;

namespace MyPhotoIndex{namespace Plugins{namespace ImageFormatProviders 
{
	public ref class RawPlugin : IImageFormatProvider
	{
	public:
		RawPlugin::RawPlugin(String^ extention):
		m_fileExtention(extention)
		{

		}

		virtual property String^ Extention
		{
			String^ get();
		}

		virtual property bool IsVideo
		{
			bool get();
		}

		virtual property bool IsCachable
		{
			bool get();
		}

		virtual property bool CanSave
		{
			bool get();
		}

		virtual property bool CanRotate
		{
			bool get();
		}


		virtual IImageMetaData^ GetImageMetaData(String^ fileName);
		virtual void SetImageMetaData(IImageData^ imageData, String^ fileName);

		virtual DateTime GetImageMediaLastUpdated(String^ fileName);
		virtual String^ GetImageMediaSignature(String^ fileName);

		virtual Image^ GetThumbnail(String^ fileName, Size size);
		Image^ GetImage(String^ rawFileName, int quality);

		virtual Image^ LoadImage(IImageData^ imageData);
		virtual Image^ LoadImage(IImageData^ imageData, Size requestedSize);

		virtual void SaveImage(Image^ image, IImageData^ imageData, String^ fileName);
		virtual void SaveImage(Image^ image, IImageData^ imageData, IO::Stream^ stream);

		virtual void Rotate(String^ fileName, RotateFlipType rotationType, Image^% thumbnail, Size% newImageSize);
		
		virtual bool Exists(String^ path);

		virtual bool CanDelete(String^ path);
        virtual void Delete(String^ path);

		virtual void CopyTo(IImageData^ imageData, String^ newMediaPath);

	private:
		String^			m_fileExtention;
		static Object^	m_lock = gcnew Object();

		Image^ LoadImage(String^ fileName, Size requestedSize);
		Image^ ExtractImage(String^ rawFileName, bool thumbnail, int quality);

		Image^ RawPlugin::GetThumbnail(String^ fileName, bool origSize, Size size);
	};
}}}
